<body>
<style>
    html, body {
        background-color: #FFF !important;
    }

    .modal-body {
        background-color: #fff;
        padding: 15px
    }

    .page-header {
        margin-top: 15px !important;
    }

    .geographic input {
        width: 100px !important;
        float: left;
        margin-right: 15px;
    }

    .new-content {
        display: inline-block;width:100%;
        padding: 15px 0px
    }

    .config_img {
        width: 45px;
        height: 45px;
        margin-top: 15px;
    }
</style>

<div class="modal-body">


    <div class="modal-header">

        <div class="assistant_header">
            <button type="button" class="close" data-dismiss="modal" close="true">
                <span aria-hidden="true">×</span>
            </button>
            <h4 class="modal-title">
                <span class="fa fa-legal"></span>&nbsp;
                编辑分类
            </h4>
        </div>
    </div>

    <div class="new-content">
        <form class="form-horizontal layui-form">

            <div class="form-group">
                <label class="col-sm-2 control-label">*分类名称:</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="name" value="{$detail.name}" placeholder="分类名称">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">排序:</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="sort" value="{$detail.sort}" placeholder="排序">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">状态:</label>
                <div class="col-sm-8">
                    <select name="status">
                        <option value="1" {if condition="$detail['status'] eq 1"} selected {/if}>启用</option>
                        <option value="2" {if condition="$detail['status'] eq 2"} selected {/if}>禁用</option>
                    </select>
                </div>
            </div>
            <input value="{$detail.id}" name="id" type="hidden">

        </form>

    </div>
    <div class="assistant_button">
        <button type="button" class="layui-btn layui-btn-primary js_quit" close="true">取消</button>
        <!--        <button type="button" class="btn btn-primary btn-sm js_add" _event="add" data-id="0" data-name="">保存</button>-->
        <button type="button" class="layui-btn js_add">保存</button>
    </div>

</div>


<script>

    var newModal = new yii.modal();

    layui.use(['form', 'layedit', 'tree', 'util', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer;


        $(".js_add").click(function () {
            var data = $("form").serializeArray();
            $.ajax({
                type: 'post',
                url: "{:URL('admin/ptt/doClassify')}",
                data: data,
                dataType: 'JSON',
                success: function (res) {
                    if (res.code != 0) {
                        layer.alert(res.msg);
                    } else {
                        window.location.href = "{:URL('admin/ptt/classify')}?role_id={$role_id}";
                    }
                },
                error: function (res) {

                }
            });

        })


        layui.form.render('select');
        form.render();


    });
</script>

</body>
